#ifndef _MAKE_LOG_H
#define _MAKE_LOG_H

#include <stdio.h>
#include <time.h>

#define LOG_FILE_PATH "/home/ubuntu/YunDisk/log/log.txt"

#define LOG(format, ...) \
do { \
    time_t now = time(NULL);\
    struct tm* t = localtime(&now);\
    FILE *fp = fopen(LOG_FILE_PATH, "a"); \
    if (fp != NULL) { \
        fprintf(fp, "[%04d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "\n", \
            t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, \
            t->tm_hour, t->tm_min, t->tm_sec, \
            __FILE__, __LINE__, ##__VA_ARGS__); \
        fclose(fp); \
    } \
} while (0)

#endif
